// ==UserScript==
// @name         淘宝自动下单
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       zhaoyuqi
// @match        https://buy.tmall.com/order/confirm_order.htm*
// @match        https://detail.tmall.com/item.htm*
// @icon         
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let toBuy = function(){
        console.log('***************************************************************')
        let btnBuy = document.getElementById('J_LinkBuy');

        if(btnBuy){
            console.log('##############  点击  ##############')
            btnBuy.click();
            location.reload()
        }
        setTimeout(toBuy,100)
    }

    let url = location.href
    if(url.indexOf('item.htm')>=0){
       toBuy();
    }


    if(url.indexOf('confirm_order.htm')>=0){
        while(true){
            let btnSubmit = document.getElementsByClassName('go-btn');
            if(btnSubmit){
                btnSubmit[0].click();
                break;
            }
        }
    }
})();